package com.cee.admin.modules.industry;

import com.cee.admin.common.BaseController;
import com.cee.common.web.result.Result;
import com.cee.domain.enums.IndustryEnum;
import com.cee.domain.modules.sys.entity.internal.IndustryCarbonEmissionIntensity;
import com.cee.ds.modules.sys.service.ISysConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author wsz
 * @since 2024/3/20
 */
@Tag(name = "行业碳排放强度均值")
@RestController
@RequestMapping("/api/industry/carbonEmissionIntensity")
public class IceiController extends BaseController {

    @Autowired
    private ISysConfigService sysConfigService;

    @Operation(summary = "获取所有")
    @GetMapping("/list")
    public Result<List<IndustryCarbonEmissionIntensity>> list() {
        return success(sysConfigService.listIndustryCei());
    }

    @Operation(summary = "更新")
    @PostMapping("/update")
    public Result<Boolean> update(@Valid @RequestBody IndustryCarbonEmissionIntensity emissionIntensity) {
        return success(sysConfigService.updateIndustryCei(IndustryEnum.getById(emissionIntensity.getIndustryId()), emissionIntensity.getAvgOutputEmissionIntensity(), emissionIntensity.getAvgOutputValueEmissionIntensity()));
    }


}
